package com.hs.controller;


import com.hs.entity.dto.CommentDTO;
import com.hs.entity.vo.CommentVO;
import com.hs.service.CommentService;
import com.hs.utils.ResultResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hs
 * @since 2023-08-05
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评论")
public class CommentController {

    @Resource
    private CommentService commentService;

    @GetMapping("/{trendId}")
    @ApiOperation("获取动态评论")
    public ResultResponse<List<CommentVO>> getCommentsByTrendId(@PathVariable Integer trendId){
        return commentService.getCommentsByTrendId(trendId);
    }

    @PostMapping("/publish")
    @ApiOperation("发表评论")
    public ResultResponse<?> publishComment(@RequestBody CommentDTO commentDTO){
        return commentService.publishComment(commentDTO);
    }
}

